package com.example.demo.redis.rediscontroller;

import com.example.demo.model.Material;
import com.example.demo.redis.service.RedisService;
import com.example.demo.util.Result;
import com.example.demo.util.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by Administrator on 2018/12/27.
 */
@RestController
public class RedisController {

    @Autowired
    private RedisService redisService;
    @GetMapping("/redisTest")
    public Result<List<Material>> redisTest(Integer id){

        return redisService.queryMaterials(id);
    }

    @PostMapping("/updateMaterialById")
    public Result<List<Material>> updateMaterialById(@RequestBody Material material){
        return redisService.updateMaterialById(material);
    }

    @GetMapping("/deleteMaterialById")
    public String deleteMaterialById(@RequestParam("id") Integer id){
        redisService.deleteMaterialById(id);
        return "删除成功";
    }
}
